# -*- coding: UTF-8 -*-
#-------------------------------------------------------------------------------
# Name:        helpers.py
# Purpose:
#
# Author:      Drago@
#
# Created:     19.09.2009
# Copyright:   (c) Drago@ 2009
# Licence:     <your licence>
#-------------------------------------------------------------------------------
#!/usr/bin/env python

import time
import iso8601
    
def ISO8601TimeToMySQL(ISO8601time):
    """
        Helper for ISO8601 time format conversion for MySQL datetime format
        
        Params:
            ISO8601time - time in ISO8601 format
        
        Returns: time in MySQL datetime format
    """
    if ISO8601time:
        # TODO: Need correct ISO 8601 time conversion        
        return time.strftime("'%Y-%m-%d %X'", iso8601.parse_date(ISO8601time).timetuple())
    else:
        return 'NULL'
